home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1996 September / JCSM Shareware Collection (JCS Distribution) (September 1996).ISO / tutorial / trac.zip / FIGIV-1.TRA < prev    next >
Text File  |  1990-01-25  |  3KB  |  54 lines

  1. 0009          0 Origin
  2. STRT     RD   X Read X (Also sets next 4 locations to zero)
  3.          LD   X Load accumulator with X
  4.          BZSTOP If X is zero jump to halt instruction
  5.          BN*+4  If X is negative, skip next 3 instructions     
  6.          LD ONE Load +1                                        
  7.          ST   S Store at S (sign)                              
  8.          BU*+6  Branch unconditionally around next 5           
  9.          LDNEG1 Load -1                                        
  10.          ST   S Store at S                                     
  11.          LDZERO Load zero                                      
  12.          SU   X Subtract X (This makes a negative X positive)  
  13.          ST   X Store back at X                                
  14.          LD ONE Load 1                                         
  15.          ST   I I=1 using index register 2                     
  16.          LD   X Load X                                         
  17.          SR0008 Shift it right 8                               
  18.          ST   Y Store at Y                                     
  19. LOOP     LD   Y Load Y (Note this is the start of a loop)      
  20.          MU ATE Multiply by 8                                  
  21.          ST   Y Store at Y                                     
  22.          LD   X Load X                                         
  23.         2SL0000 Shift left by I (Contents of register 2)       
  24.          SR0008 Shift right 8 (This isolates an octal digit)   
  25.          AD   Y Add previous Y                                 
  26.          ST   Y Store back at Y                                
  27.          LD   I Load I                                         
  28.          AD ONE Add 1                                          
  29.          ST   I Store at I                                     
  30.          SUNINE Subtract 9 to see if done                      
  31.          BNLOOP If negative repeat loop                        
  32.          LD   X Load X                                         
  33.          MU   S Multiply by sign                               
  34.          ST   X Store at X                                     
  35.          LD   Y Load Y                                         
  36.          MU   S Multiply by sign                               
  37.          ST   Y Store at Y                                     
  38.          PC   X Print X, Y                                     
  39.          BUSTRT Branch back to start                           
  40. STOP     HT0000 Halt
  41. 0001          0 Re-origin to define I
  42.    I          0
  43. 1499          0 Re-origin for constants
  44. ZERO          0 Zero
  45.  ONE          1 One
  46.    S          0
  47. NEG1         -1 Negative one
  48.  ATE          8 Eight
  49. NINE          9 Nine
  50. 0999          0 Re-origin for read area
  51.    X          0
  52.    Y          0
  53.          ENSTRT End of code and starting location
  54.